<%@ page import="mybatis.pojo.Admin" %>
<%@ page import="mybatis.services.AdminService" %><%--
  Created by IntelliJ IDEA.
  User: Dell
  Date: 2022/7/4
  Time: 10:37
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
<%
    request.setCharacterEncoding("utf-8");
    String loginName = request.getParameter("loginname");
    String pwd = request.getParameter("pwd");
    Admin admin = AdminService.ME.login(loginName, pwd);
    //if (loginName.startsWith("java78") && pwd.equals("123"))
    if (admin!=null){
        Cookie cookie = new Cookie("loginname", loginName);

        cookie.setMaxAge(86400*7);
        response.addCookie(cookie);
       session.setAttribute("USER_LOGIN", loginName);
//        session.setAttribute("upass", pwd);
        response.sendRedirect("welcome.jsp");
    } else {
        request.setAttribute("msg", "用户名或者密码错误");
        request.getRequestDispatcher("login.jsp").forward(request, response);
    }

%>
</body>
</html>
